package org.jeecg.modules.demo.weixin.douyin.base;

import lombok.Data;

import java.io.Serializable;

/**
 * code message类
 * @author: rain
 * TODO
 * 2023/3/21 15:32
 */

@Data
public class CodeMsg<T> implements Serializable {

    private Integer errorCode;


    private String errorMsg;


    private Boolean success;


    private T data;

    public static  CodeMsg succeses(){
        return succeses(null);
    }
    public static  CodeMsg succeses(Object data){
        return succeses("",data);
    }

    public static  CodeMsg succeses(String errorMsg,Object data){
        CodeMsg<Object> objectCodeMsg=new CodeMsg<>();
        objectCodeMsg.setErrorCode(200);
        objectCodeMsg.setErrorMsg(errorMsg);
        objectCodeMsg.setSuccess(true);
        objectCodeMsg.setData(data);
        return objectCodeMsg;
    }
    public static  CodeMsg error(Integer errorCode,String errorMsg,Object data){
        CodeMsg<Object> objectCodeMsg=new CodeMsg<>();
        objectCodeMsg.setErrorCode(errorCode);
        objectCodeMsg.setErrorMsg(errorMsg);
        objectCodeMsg.setData(data);
        objectCodeMsg.setSuccess(false);
        return objectCodeMsg;
    }

}
